package main

import (
	"github.com/gin-gonic/gin"
	"html/template"
	"net/http"
)

func main() {
	router := gin.Default()
	router.LoadHTMLFiles("templates/form.html")
	//设计页面的编码
	router.SetHTMLTemplate(template.Must(template.New("").Delims("[[", "]]").ParseGlob("templates/*.html")))
	//提供表单页面
	router.GET("/", func(c *gin.Context) {
		c.HTML(http.StatusOK, "form.html", nil)
	})

	router.POST("/submit", func(c *gin.Context) {
		name := c.PostForm("name")
		c.String(http.StatusOK, "提交姓名为:"+name)
	})
	router.Run()
}
